<template>
  <div class="app-container">
    <div class="filter-container" >
      <!--<div style="height: 30px;">
        <span>营业汇总表</span>
      </div>-->
      <searchBar @searchEvent= "handleFilter"/>
    </div>
    <div style="height: 50px;margin-top: 20px;padding: 0 12px; background:#eee; line-height: 50px;">
      <span>品牌优惠明细报表</span>
      <el-button v-waves style="float: right; margin-top: 7px;" class="filter-item" type="primary" @click="download">月报表</el-button>
    </div>
    <el-table
      v-loading="listLoading"
      :key="tableKey"
      :data="overAll"
      __height="550"
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="品牌名称" fixed align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="优惠总计" fixed align="center" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.discountSum && scope.row.discountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="线上优惠券" align="center">
        <el-table-column label="现金券" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.cashCoupon && scope.row.cashCoupon || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="现金券产品券" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.productCoupon && scope.row.productCoupon || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="POS端折扣" align="center">
        <el-table-column label="免单" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.exemptionMoney && scope.row.exemptionMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="按金额优惠" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.posDiscountByMoney && scope.row.posDiscountByMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="按折扣率" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.discountRateMoney && scope.row.discountRateMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="抹零" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.realEraseMoney && scope.row.realEraseMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="赠菜" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.grantMoney && scope.row.grantMoney || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="外卖折扣" align="center" >
        <el-table-column label="美团外卖" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.meituanWmDiscount && scope.row.meituanWmDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="饿了么外卖" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.elemaWmDiscount && scope.row.elemaWmDiscount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="自定义折扣" align="center" >
        <el-table-column label="招商银行减50" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.cmbcDiscount && scope.row.cmbcDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="会员卡9折" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.memberDiscount && scope.row.memberDiscount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>

      <el-table-column label="充值赠送支付" width="120px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.rechargeDiscount && scope.row.rechargeDiscount || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="线下代金券" width="120px" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.offlineVoucher && scope.row.offlineVoucher || 0 }}</span>
        </template>
      </el-table-column>
    </el-table>

    <div style="height: 50px;margin-top: 20px;padding: 0 12px; background:#eee; line-height: 50px;">
      <span>店铺优惠明细报表</span>
      <el-button v-waves style="float: right; margin-top: 7px;" class="filter-item" type="primary" @click="download">月报表</el-button>
    </div>
    <el-table
      v-loading="listLoading"
      :key="1"
      :data="list"
      height="550"
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="店铺名称" fixed align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="优惠总计" fixed align="center" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.discountSum && scope.row.discountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="线上优惠券" align="center">
        <el-table-column label="现金券" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.cashCoupon && scope.row.cashCoupon || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="现金券产品券" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.productCoupon && scope.row.productCoupon || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="POS端折扣" align="center">
        <el-table-column label="免单" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.exemptionMoney && scope.row.exemptionMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="按金额优惠" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.posDiscountByMoney && scope.row.posDiscountByMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="按折扣率" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.discountRateMoney && scope.row.discountRateMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="抹零" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.realEraseMoney && scope.row.realEraseMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="赠菜" width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.grantMoney && scope.row.grantMoney || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="外卖折扣" align="center" >
        <el-table-column label="美团外卖" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.meituanWmDiscount && scope.row.meituanWmDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="饿了么外卖" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.elemaWmDiscount && scope.row.elemaWmDiscount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="自定义折扣" align="center" >
        <el-table-column label="招商银行减50" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.cmbcDiscount && scope.row.cmbcDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="会员卡9折" width="120px" align="center" >
          <template slot-scope="scope">
            <span>{{ scope.row.memberDiscount && scope.row.memberDiscount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>

      <el-table-column label="充值赠送支付" width="120px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.rechargeDiscount && scope.row.rechargeDiscount || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="线下代金券" width="120px" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.offlineVoucher && scope.row.offlineVoucher || 0 }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" />

  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import waves from '@/directive/waves' // Waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

import searchBar from '@/pages/common/searchBar'
import ReportSearchMixin from '@/pages/common/mixin/ReportSearch.js'

export default {
  name: 'Youhuimingxi',
  components: { searchBar, Pagination },
  directives: { waves },
  filters: {

  },
  mixins: [ReportSearchMixin],
  data() {
    return {

      tableKey: 0,
      overAll: [], // 品牌的总览数据
      list: [], // 下边的列表数据
      total: 0,
      listLoading: true,
      listQuery: {
        pageNum: 1,
        pageSize: 10,
        beginDate: parseTime(new Date().getTime(), '{y}-{m}-{d} 00:00:00'),
        endDate: parseTime(new Date().getTime(), '{y}-{m}-{d} {h}:{i}:{s}')
      },
      overAllUrl: '/service-report/businessReport/listDiscountReport' // 概览接口地址
      // listUrl: '/service-report/data/ShopList' // 列表接口地址

    }
  },
  created() {
    // this.getList()
    this.fetchData()
  },
  methods: {

    download() {

    },
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    }
    /* handleFilter(date) {
      this.beginDate = date.beginDate
      this.endDate = date.endDate
      console.log('date', date)
      this.listQuery.page = 1
      this.getList()
    },
    sortChange(data) {
      const { prop, order } = data
      if (prop === 'id') {
        this.sortByID(order)
      }
    }*/

  }
}
</script>
